package com.lgqz.himalayafm.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.lgqz.himalayafm.bean.RadioProvinceEntity;
import com.lgqz.himalayafm.fragment.RadioProvinceFragment;

import java.util.List;

/**
 * Radio 省市台的适配器
 * Created by Administrator on 2016/12/13/013.
 */
public class RadioProvinceAdapter  extends FragmentPagerAdapter{
    private List<RadioProvinceEntity.ProvinceEntity> mProvinceTabDatas;

    public RadioProvinceAdapter(FragmentManager fm,
                                List<RadioProvinceEntity.ProvinceEntity> mProvinceTabDatas) {
        super(fm);
        this.mProvinceTabDatas = mProvinceTabDatas;
    }

    public RadioProvinceAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        return RadioProvinceFragment.newInstance(mProvinceTabDatas.get(position).
                getProvinceCode() );
    }

    @Override
    public int getCount() {
        return mProvinceTabDatas.size();
    }

    /**
     * tab和viewpage配合
     * @param position
     * @return
     */
    @Override
    public CharSequence getPageTitle(int position) {
        return mProvinceTabDatas.get(position).getProvinceName();
    }
}